/**
 * @author:ruimin
 * @date:2016年10月25日
 * @description:
 */
$(function () {  
	$("#functionNav").attr("href",navAddr);
	//加载日期控件
	$('.dateInput').datetimepicker({
		format: 'yyyy-mm-dd',
        forceParse: 0,
        todayBtn:  1,
        autoclose: 1,
        todayHighlight: 1,
        minView: 2,
        bootcssVer:3
});
  
  //获取征集单号查询条件
  var params_zjdh =$("#form_zjd").serializeObject();
  //获取征集单号查询条件
  var params_zjcp =$("#form_zjcp").serializeObject();

  //初始化征集单列表Table
  createTableOrderBy('#listtbl','antiques/zjquery.getZhengJiList.do','id',listtblColumns,params_zjdh);
  //初始化征集藏品列表Table
  createTableOrderBy('#listtbl2','antiques/zjquery.getCangPinList.do','id',listtbl2Columns,params_zjcp);  
  
  //级联下拉框Id
  var doms_sd = ["sd1","sd2","sd3","sd4"];
  selectFour(url_nd,doms_sd);
  //设置来源类型下拉列表
  ajaxFunc("get",true,'antiques/sysmanage.getIdAndNameInJb.do?tableName=jb_lyfs',"",getSelectOptions,"lylx");
  
  //点击征集单查询-查询按钮
  $("#queryBtn_zjd").click(function(){
	  var params_zdjh = $("#form_zjd").serializeObject();   
	  $("#listtbl").bootstrapTable('refresh',{query:params_zdjh});
  });
  //点击征集藏品-查询按钮
  $("#queryBtn_zjcp").click(function(){
	  var params_lb = $("#form_zjcp").serializeObject(); 
	  $("#listtbl2").bootstrapTable('refresh',{query:params_lb});
  });
})

//征集单表头
var listtblColumns=[{
    checkbox: true
  }, {
    field: 'djbh',
    title: '单据编号',
    sortable:true    	
  }, {
    field: 'bt',
    title: '标题',
    sortable:true,
    formatter: function(value, row, index) {
  	  return '<a href="zhengJiDjInfo.html?djbh='+escape(row.djbh)+'">'+value+'</a>';
    }
  }, {
    field: 'djdw',
    title: '点交单位',
    sortable:true
  }, {
    field: 'djjbr',
    title: '点交单位经办人',
    sortable:true
  }, {
    field: 'sqbmmc',
    title: '申请部门',
    sortable:true
  }, {
    field: 'sqrmc',
    title: '申请人',
    sortable:true
  }];

//征集藏品表头
var listtbl2Columns=[{
    checkbox: true
  }, {
    field: 'rgh',
    title: '入馆号',
    sortable:true
  }, {
    field: 'mc',
    title: '名称',
    sortable:true,
    formatter: function(value, row, index) {
    	  return '<a href="zhengJiInfo.html?djbh='+row.djbh+'&id='+row.id+'">'+value+'</a>';
    }
  }, {
    field: 'sjsl',
    title: '实际数量',
    sortable:true,
    formatter: function(value, row, index) {
	  	  return value + (row.sjsldw==undefined?"":row.sjsldw);
	  	}
  }, {
    field: '',
    title: '时代',
    sortable:true,
    formatter:function(value, row, index) {
    	if(row.sd4!="")
    		return row.sd4;
    	else if(row.sd4=="" && row.sd3!="")
    		return row.sd3;
    	else if(row.sd3=="" && row.sd2!="")
    		return row.sd2;
    	else
    		return row.sd1;
    }
  }, {
    field: 'lylx',
    title: '来源类型',
    sortable:true
  }];

//生成图片列表
function creatImgList(data){
	var tHtml = "";
	if(data != null){
		$.each(data,function(index,value){
			tHtml += "<div>";
			tHtml += "<a href='collectionDetail.html'><img src='../../resources/images/"+value["daiBiaoYingXiang"]+"'></a>";
			tHtml += "<p><a href='collectionDetail.html'>"+value["mingCheng"]+"</a></p>";
			tHtml += "</div>";
		});
	}
	$(".imglist").html(tHtml);
}